package com.ssm.service.impl;

import com.ssm.dao.LiseDao;
import com.ssm.pojo.Lise;
import com.ssm.pojo.PageInfo;
import com.ssm.service.LiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.function.ObjDoubleConsumer;

@Service
public class LiseServiceImpl implements LiseService{

    @Autowired
    private LiseDao liseDao;

    @Override
    public List<Lise> getLise() {
        return liseDao.getLise();
    }

    @Override
    public PageInfo<Lise> getLiseList(Lise lise, int pageNum, int pageSize) {
        Integer count = liseDao.getLiseCount(lise);
        PageInfo<Lise> pageInfo = new PageInfo<>();
        pageInfo.setTotalCount(count);
        pageInfo.setPageSize(pageSize);
        pageInfo.setPageNum(pageNum);
        if (count > 0) {
            lise.setPageSize(pageSize);
            lise.setOffset((pageNum - 1) * pageSize);
            List<Lise> users = liseDao.getLiseBy(lise);
            pageInfo.setResult(users);
        }
        return pageInfo;
    }

    @Override
    public Lise getLiseById(Integer id) {
        return liseDao.getLiseById(id);
    }
}
